﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UPMS.Core.Domain.Mapping
{
    public class ApplicationMap : EntityTypeConfiguration<Application>
    {
        public ApplicationMap()
        {
            this.ToTable("Upms_tbl_Application");
            this.Property(a => a.HostId).HasColumnName("HostId").IsRequired();
            this.Property(a => a.Name).HasColumnName("Name").IsRequired().HasMaxLength(64);

            this.HasRequired(a => a.Host).WithMany(h => h.Applications).HasForeignKey(a => a.HostId);
            this.HasMany(a => a.Modules).WithRequired(m => m.Application).HasForeignKey(m => m.ApplicationId);
        }
    }
}
